<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <%@ include file="/common/common.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link href="${ctx}/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${ctx}/static/plugins/validationEngine/css/validationEngine.jquery.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="content">
	
    <form class="form-horizontal" id="updateForm">
	    <br>
		<br>
		<br>
		<input type="hidden" name="id" value="${role.id}">
        <div class="form-group">
            <label for="roleName" class="col-sm-4 control-label"><font color="red">*</font>角色名称:</label>
            <div class="col-sm-3">
                <input type="text" class="form-control validate[required]" id="roleName" name="roleName" value="${role.roleName}" placeholder="请输入角色名称">
            </div>
        </div>
        <div class="form-group">
            <label for="description" class="col-sm-4 control-label">角色描述:</label>
            <div class="col-sm-3">
                <input type="text" class="form-control validate[required]" id="description" name="description" value="${role.description}" data-fun="dataFunDemo" placeholder="请输入角色描述">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-10 text-center">
                <button type="button" id="updateBtn" class="btn btn-primary">修改</button>
            </div>
        </div>
    </form>
</div>
<script src="${ctx}/static/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script src="${ctx}/static/bootstrap/js/bootstrap.min.js"></script>
<script src="${ctx}/static/plugins/validationEngine/jquery.validationEngine-zh_CN.js"></script>
<script src="${ctx}/static/plugins/validationEngine/jquery.validationEngine.js"></script>
<script>
    $(function () {
    	$("#updateForm").validationEngine({ 
    		promptPosition: "topRight", 
    		validationEventTriggers:"keyup blur", 
    		success :  false,
    		failure : function() { callFailFunction()  }
   		});
    	
    	$("#updateBtn").click(function(){
	    	var flag = $("#updateForm").validationEngine("validate");
	    	if(!flag){
	     		return false;
	    	}
    		//提交数据
        	$.ajax({
        		async       : false,
        		type 		: "POST",
        	    url		    : "${ctx}/api/role/update",
        		data 		: $("#updateForm").serialize(),
        		success 	: function( d ) {
        			if(d.code=="200"){
        				alert(d.message);
        				window.location.href="${ctx}/api/role/listPage"
        			} else {
        				alert(d.message);
        			}
        		}
        	});
    	});
    });
</script>
</body>
</html>